package com.itdianzi.controller.changePassword;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itdianzi.controller.base.BaseController;
import com.itdianzi.domain.system.Module;
import com.itdianzi.domain.system.User;
import com.itdianzi.service.system.ModuleService;
import com.itdianzi.service.system.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/changePassword")
public class ChangePasswordController extends BaseController {
    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    public String list() {

        return "cargo/changePassword/changePassword";
    }

    @RequestMapping("/change")
    public String login(String password) {

        System.out.println(password);

        loginUser.setPassword(password);


        try {


            userService.updateByEmail(loginUser);

            //跳转主页
            return "cargo/changePassword/successChange";
        } catch (AuthenticationException e) {
            //登录失败
            request.setAttribute("error","修改失败，请稍后重试");
            return "forward:/login.jsp";
        }

    }
}
